<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::group(array('before' => 'auth'), function() {
	/*View::composer('includes.header-icons', function($view) {
		$pages = Fbpage::where('user_id', Auth::user()->id)->get();
    	$view->with('pages', $pages);
	});*/
	Route::get('users', 'UsersController@index');
	Route::get('multi-product-ads', 'HomeController@multiProductAds');
	Route::post('create-ads', 'HomeController@processMultiProductAds');
	Route::get('mpa-final', 'HomeController@mpaFinal');
	Route::post('payment', array('before' => 'csrf', 'uses' => 'HomeController@payment'));
	Route::get('page-post', 'FbAudienceController@pagePost');
	Route::post('create-page-post', 'FbAudienceController@createPagePost');

	// custom audience scanner
	Route::group(array('prefix' => 'fb-audience'), function() {
		Route::match(array('GET', 'POST'), 'get-post', 'FbAudienceController@getPost');
		Route::get('get-uid-by-post', function() {
			FbAudienceController::getIdsByPosts();
		});
		Route::match(array('GET', 'POST'), 'mass-importer', 'FbAudienceController@csvMassImport');
	});

	Route::get('page-notifications', 'HomeController@pageNotifications');
});
Route::get('/', 'HomeController@index');
Route::get('login', 'UsersController@showLogin');
Route::post('login', 'UsersController@doLogin');
Route::get('logout', function() {
	Auth::logout();
	return Redirect::to('login');
});
Route::get('login/fb', 'UsersController@loginFacebook');
Route::get('pricing', 'HomeController@pricing');
Route::get('testnode', 'FbAudienceController@checknode');
Route::match(array('GET', 'POST'), 'tabs', 'FbAudienceController@pageTab');

Route::match(array('GET', 'POST'), 'fbcallback', 'FbAudienceController@callback');
Route::post('contact-us', 'HomeController@contactus');